package com.wn.pettyloan.util;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: pettyloan
 * @ClassName wenjian
 * @description:
 * @author: 韩旭
 * @create: 2022-12-14 14:52
 **/
public class wenjian {


    public static void main(String[] args) {
        // 指定文件夹路径
        List<String> anImport = wenjian.getImport("F:\\workplace\\vscode\\pettyloan_front\\pettyloan_vue\\src\\components");
        for (String s : anImport) {
            System.out.println(s);
        }


    }

    public static List<String> getImport(String path){
        List<String> list = new ArrayList<>();
        File folder = new File(path);
        File[] files = folder.listFiles();
        for (File file : files) {
            if(file.isDirectory()) {
                String directoryName = file.getName();
                File[] filess = file.listFiles();
                for (File f : filess) {
                    if(f.getName().endsWith(".vue")){
                        String name = f.getName().substring(0,f.getName().length() - 4);
                        String str = "import " + name + " from '@/components/"+directoryName + "/" + name + "'";
                        list.add(str);
                    }
                }
            }
        }

        return list;
    }


}